<%
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", -1); //prevents caching at the proxy server
%>
<%@page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
<%@ include file="Connections/conDB.jsp" %>
<% int validaSession = 2; %>
<%@ include file="Connections/session.jsp" %>

<%
String campo1 = request.getParameter("campo1");
String campo2 = request.getParameter("campo2");
String rsId_icono = "";
String rsDescripcion = "";
String rsImagen = "";

Driver DriverRs = (Driver)Class.forName(MM_conDB_DRIVER).newInstance();
Connection ConnRs = DriverManager.getConnection(MM_conDB_STRING,MM_conDB_USERNAME,MM_conDB_PASSWORD);
//String query = "SELECT * FROM transporte ORDER BY nombre ASC";
String query = "SELECT id_icono, descripcion, imagen "+
				"FROM trans_icono "+
				"ORDER BY descripcion ASC";
PreparedStatement StatementRs = ConnRs.prepareStatement(query);
ResultSet Rsquery = StatementRs.executeQuery();

%>
<html>
<head>
<title>CIMA v2 - Iconos Transporte</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="miestilo.css" type="text/css">
<script>
// ------
	function formSubmit() {
		if (aceptar()) {
		}
	}
//--------
	function aceptar() {
		var doc = document.form1;
		if (doc.opcion.value!="") {
			//alert(doc.opcion.value);
			obj1 = eval(<%="window.opener.form1."+campo1%>);
			obj2 = eval(<%="window.opener.form1."+campo2%>);
			if (obj1 && obj2) {
				inicio = 0;
				fin = doc.opcion.value.indexOf("|",inicio);
				obj1.value = doc.opcion.value.substring(inicio,fin-1);
				//alert(obj1.value);
				inicio = fin+2;
				obj2.value = doc.opcion.value.substring(inicio,doc.opcion.value.length);
				//alert(obj2.value);
				window.close();
				return true;
			}
		} else {
			alert("Escoja un Icono para el Transporte.");
			return false;
		}
	}	
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" background="images/fondo.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<br>
<center>
<form name="form1">
  <table width="250" border="0" cellspacing="0" cellpadding="0">
    <tr align="center"> 
      <td colspan="4" class="titulos">Iconos Transporte</td>
    </tr>
      <tr> 
        <td class="titcolumna">&nbsp;</td>
        <td class="titcolumna">&nbsp;</td>
        <td class="titcolumna" align="center">Descripci&oacute;n</td>
        <td class="titcolumna" align="center">Imagen</td>
      </tr>
		<%
		int num = 0;
		 while (Rsquery.next()) {
		 	num++;
			rsId_icono = Rsquery.getString("id_icono");
			rsDescripcion = Rsquery.getString("descripcion");
			rsImagen = Rsquery.getString("imagen");
		 	
		%>
      <tr> 
        <td align="center"><%=num%></td>
        <td align="center"> 
          <input type="radio" name="rbIcono" value="<%=rsId_icono+" | "+rsDescripcion%>" onClick="document.form1.opcion.value=this.value">
        </td>
        <td><%=rsDescripcion%></td>
        <td align="center"><%=rsImagen!=null?"<img src=\"images/"+rsImagen+"\" width=\"40\">":"&nbsp;"%></td>
      </tr>
	  <%
	    }
	  %>
  </table>
  <br>
  <table width="200" border="0" cellspacing="0" cellpadding="0">
  <tr>
      <td align="center"><input type="hidden" name="opcion">
	  <a href="javascript:formSubmit()"><img src="images/bAceptar.gif" width="82" height="18" border="0"></a>&nbsp;
	  <a href="javascript:window.close()"><img src="images/bCerrar.gif" width="82" height="18" border="0"></a></td>
  </tr>
</table>
</form>
</center>
</body>
<HEAD>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</HEAD>
</html>
